package web;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import biz.UserBiz;
import entity.User;

public class QueryPageServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
    
    public QueryPageServlet() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		UserBiz userbiz =  new UserBiz();
		String curpage = request.getParameter("curpage");
		
		List<User> list = userbiz.queryUser(Integer.parseInt(curpage));
		int countPages = userbiz.getPageCounts();
		
		request.setAttribute("list", list);
		request.setAttribute("counts", countPages);
		request.setAttribute("curpage", curpage);
		String flag = request.getParameter("flag");
		if(flag!=null)
			request.setAttribute("flag", Boolean.parseBoolean(flag));
		request.getRequestDispatcher("ViewUser.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
